/*
 * Copyright 2006-2008 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package net.martinimix.beans.bind;

import com.bluemartini.dna.DNAList;

/**
 * Provides a business object to Java bean binder.
 * 
 * @author Scott Rossillo
 *
 */
public interface BeanBinder {

	/**
	 * Returns true if this bean binder supports binding beans of
	 * the given type.
	 * 
	 * @param type the <code>Class</code> type to test for support
	 * 
	 * @return <code>true</code> if this bean binder support binding
	 * beans of the given <code>type</code>; <code>false</code> otherwise
	 */
	public abstract boolean supports(Class type);

	/**
	 * Returns an object of the target type whose fields are bound
	 * to the properties from the given source list.
	 * 
	 * @param source the <code>DNAList</code> providing the properties
	 * to be mapped fields on the given <code>target</code>; cannot
	 * be <code>null</code>
	 *  
	 * @param target an <code>Object</code> of the required type whose
	 * fields shall be bound the properties from the given <code>source</code>
	 *  
	 * @return the <code>target</code> with its fields bound to the
	 * properties from the given <code>source</code>
	 */
	public abstract Object bind(DNAList source, Object target);

}
